﻿using SAPbobsCOM;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CompanySyncProject
{
    public class DICancelMarketingDoc : BaseRun
    {
        public DICancelMarketingDoc(Company co, System.IO.StreamWriter lo)
            : base(co, lo)
        {

        }

        public override void Run()
        {
            oCompany.XmlExportType = BoXmlExportTypes.xet_ExportImportMode;
            oCompany.XMLAsString = true;

            SAPbobsCOM.Documents inv = oCompany.GetBusinessObject(BoObjectTypes.oInvoices);
            inv.CardCode = "cpjoyintnpftgoi";
            inv.DocDueDate = DateTime.Now;
            inv.Lines.ItemCode = "bisaidovmlddfkoxetli";
            inv.Lines.Quantity = 1;
            int ret1 = inv.Add();

            string errMsg = oCompany.GetLastErrorDescription();
            int errcode = oCompany.GetLastErrorCode();

            string invkey = oCompany.GetNewObjectKey();
            string invtype = oCompany.GetNewObjectType();

            SAPbobsCOM.Documents inv1 = oCompany.GetBusinessObject(BoObjectTypes.oInvoices);
            int invkeyint;
            int.TryParse(invkey, out invkeyint);
            inv1.GetByKey(invkeyint);

            SAPbobsCOM.Documents inv2 = inv1.CreateCancellationDocument();
            inv2.Add();
            invkey = oCompany.GetNewObjectKey();
            invtype = oCompany.GetNewObjectType();

        }
    }
}
